﻿using Clothes.BLL;
using Clothes.Comment;
using Clothes.IBLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YongHu_UI.Model;

namespace YongHu_UI
{
    public partial class Mobile : System.Web.UI.Page
    {
        AccountManager accountManager = new AccountManager();
        CLLoginIBLL cLLogin = new CLLoginBLL();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                
                var result = accountManager.LoginByMobileNumber(txtMobileNumber.Text, txtPassword.Text);
                var deng = cLLogin.SelectBLL(txtMobileNumber.Text, txtPassword.Text);
                int guan = deng.Manager;
                //if (result.StatusCode == StatusCode.Succeed)
                //{
                //    var user = result.ReadResult();
                   IdentityManager.SaveUser(deng);
                    if (guan == 0)
                    {
                        Response.Redirect("index.aspx");
                    }
                    else
                    {
                        Response.Redirect("table.aspx");
                    }
                //}
                //else
                //{
                //    //Response.Write();
                //    ClientScript.RegisterStartupScript(GetType(), "loginerror", $"alert('{result.Massage}')");
                //}
            }
        }
    }
}